package com.aier.admin.action;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.aier.common.dao.ICommonDAO;
import com.aier.proxy.service.IProxyService;
import com.aier.school.entity.SchoolIcCard;
import com.aier.school.service.ISchoolIcCardService;

@Scope("prototype")
@Component("adminRecoverSchoolCardAction")
public class AdminRecoverSchoolCardAction extends AdminBaseAction {

    private static final long serialVersionUID = 1L;

    @Resource(name = "schoolIcCardService")
    private ISchoolIcCardService schoolIcCardService;

    // 当前页
    private int page;
    // 每页显示记录数
    private int page_size;
    // 总页数
    private int page_count;
    // 总数
    private int count;

    private int s;

    private String sname;     // 学校名称
    private String cardnum;   //卡号
    private short state = -1; //学校卡状态 10:启用,20:注销
    private List<SchoolIcCard> schoolIcCardList;// 学校拥有的卡
    private Long icid;

    @Override
    public String execute() {
        return SUCCESS;
    }
    
    @SuppressWarnings("unchecked")
    public String search_admin() {
        s = 0;
        if (page <= 0) {
            page = 1;
        }
        try {
            Map<String, Object> map = schoolIcCardService.searchSchoolCardsByConditionNew(
                    page, IProxyService.PROXY_CARD_LIST_PAGESIZE,sname,
                    cardnum,state);
            if (null != map) {
                schoolIcCardList = (List<SchoolIcCard>) map.get(ICommonDAO.OBJ_LIST);
                if (null != schoolIcCardList) {
                    s = 1;
                }
                page = (Integer) map.get(ICommonDAO.PAGE);
                page_size = (Integer) map.get(ICommonDAO.PAGE_SIZE);
                page_count = (Integer) map.get(ICommonDAO.PAGE_COUNT);
                count = (Integer) map.get(ICommonDAO.COUNT);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return SUCCESS;
    }

    /**
     * 学校回收ic卡
     * @return
     */
    public String delete(){
        s = schoolIcCardService.deleteIcard(icid);
        return SUCCESS;
    }
    

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getPage_size() {
        return page_size;
    }

    public int getPage_count() {
        return page_count;
    }

    public int getCount() {
        return count;
    }

    public int getS() {
        return s;
    }

    public void setSchoolIcCardService(ISchoolIcCardService schoolIcCardService) {
        this.schoolIcCardService = schoolIcCardService;
    }

    public void setSname(String sname) {
        this.sname = sname;
    }

    public void setCardnum(String cardnum) {
        this.cardnum = cardnum;
    }

    public void setState(short state) {
        this.state = state;
    }

    public List<SchoolIcCard> getSchoolIcCardList() {
        return schoolIcCardList;
    }

    public void setIcid(Long icid) {
        this.icid = icid;
    }
}
